index.js ➔ createRouter   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 68
Code Lines 50

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 50
nc 1
nop 2
dl 0
loc 68
c 0
b 0
f 0
cc 1
rs 8.6363

1 Function

Rating   Name   Duplication   Size   Complexity  
A index.js ➔ ... ➔ ??? 0 1 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
import Vue from 'vue'
2
import Router from 'vue-router'
3
4
// Containers
5
import Full from '../containers/Full'
6
7
// Views
8
9
import MainWindow from '../views/MainWindow'
10
import DonateWindow from '../views/DonateWindow'
11
import RecurrentWindow from '../views/RecurrentWindow'
12
import RecurrentDonateWindow from '../views/RecurrentDonateWindow'
13
import StatusWindow from '../views/StatusWindow'
14
15
Vue.use(Router)
16
17
export function createRouter(base, i18n) {
18
  return new Router({
19
    mode: 'history',
20
    base: base,
21
    linkActiveClass: 'open active',
22
    scrollBehavior: () => ({ y: 0 }),
23
    routes: [
24
      {
25
        path: '/campaign/',
26
        name: 'campaign',
27
        component: Full,
28
        meta: {
29
          label: i18n.t('labels.admin.title')
30
        },
31
        children: [
32
          {
33
            path: ':id',
34
            name: 'id',
35
            component: MainWindow,
36
            meta: {
37
              label: i18n.t('labels.admin.campaigns.title')
38
            }
39
          },
40
          {
41
            path: ':id/donate',
42
            name: 'donate',
43
            component: DonateWindow,
44
            meta: {
45
              label: i18n.t('labels.admin.campaigns.title')
46
            }
47
          },
48
          {
49
            path: ':id/donate/status',
50
            name: 'donateStatus',
51
            component: StatusWindow,
52
            meta: {
53
              label: i18n.t('labels.admin.campaigns.title')
54
            }
55
          },
56
          {
57
            path: ':id/recurrent',
58
            name: 'recurrent',
59
            component: RecurrentWindow,
60
            meta: {
61
              label: i18n.t('labels.admin.campaigns.title')
62
            }
63
          },
64
          {
65
            path: ':id/recurrent/donate',
66
            name: 'recurrentDonate',
67
            component: RecurrentDonateWindow,
68
            meta: {
69
              label: i18n.t('labels.admin.campaigns.title')
70
            }
71
          },
72
          {
73
            path: ':id/recurrent/status',
74
            name: 'recurrentStatus',
75
            component: StatusWindow,
76
            meta: {
77
              label: i18n.t('labels.admin.campaigns.title')
78
            }
79
          }
80
        ]
81
      }
82
    ]
83
  })
84
}
85